package com.indeep.indeepmasterstation.mapper;



import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.indeep.indeepmasterstation.mapper.po.AppMessageListPO;
import org.apache.ibatis.annotations.*;

import java.sql.Timestamp;
import java.util.List;

@Mapper
public interface AppMessageListMapper extends BaseMapper<AppMessageListPO> {
//
//    // 查询消息记录
//    @Select("<script>" +
//            "SELECT apc.type postType,ml.id,ml.message_type,ml.skip_id,ml.content,ml.activity_id,if(ml.status=0,'false','true') fet,ml.src_id, yu.username,  DATE_FORMAT(ml.update_time, '%Y-%m-%d %H:%i:%s') updateTime " +
//            "FROM app_message_list ml " +
//            "LEFT JOIN app_user yu ON ml.src_id = yu.id " +
//            "left join app_post_content apc on ml.skip_id = apc.id" +
//            "<where>" +
//            "NOW() > ml.invisible_time and " +
//            "ml.user_id = #{userId} AND " +
//            "ml.src_id != #{userId}  " +
//            "<if test='type != null'>" +
//            "AND (" +
//            "<choose>" +
//            "<when test='type == 1'>" +
//            "ml.message_type = 3 OR ml.message_type = 5" +
//            "</when>" +
//            "<when test='type == 2'>" +
//            "ml.message_type = 14 OR ml.message_type = 2 OR ml.message_type = 15" +
//            "</when>" +
//            "<when test='type == 3'>" +
//            "ml.message_type = 6" +
//            "</when>" +
//            "<otherwise>" +
//            "ml.message_type>20 or ml.message_type = 11 or ml.message_type = 12 or ml.message_type = 13 " +
//            "</otherwise>" +
//            "</choose>" +
//            ")" +
//            "</if>" +
//            "</where>" +
//            "ORDER BY ml.update_time DESC " +
//            "LIMIT #{pageBegin}, #{pageSize}" +
//            "</script>")
//    List<AppMessageListPO> selectMessageList(@Param("pageBegin") Integer pageBegin, @Param("pageSize") Integer pageSize, @Param("userId") Long userId, @Param("type") Integer type);
//
//
//    // 查询消息记录总数
//    @Select("<script>" +
//            "SELECT count(1) " +
//            "FROM app_message_list ml " +
//            "LEFT JOIN app_user yu ON ml.src_id = yu.id " +
//            "<where>" +
//            "ml.user_id = #{userId} AND " +
//            "ml.src_id != #{userId} " +
//            "<if test='type != null'>" +
//            "AND (" +
//            "<choose>" +
//            "<when test='type == 1'>" +
//            "ml.message_type = 3 OR ml.message_type = 5" +
//            "</when>" +
//            "<when test='type == 2'>" +
//            "ml.message_type = 14 OR ml.message_type = 2 OR ml.message_type = 15" +
//            "</when>" +
//            "<when test='type == 3'>" +
//            "ml.message_type = 6" +
//            "</when>" +
//            "<otherwise>" +
//            "ml.message_type>20  or ml.message_type = 11 or ml.message_type = 12 or ml.message_type = 13 " +
//            "</otherwise>" +
//            "</choose>" +
//            ")" +
//            "</if>" +
//            "</where>" +
//            "</script>")
//    int selectMessageListCount(MessageListQuery messageListQuery);
//
//
//    @Select("<script>" +
//            "SELECT count(1) " +
//            "FROM app_message_list ml " +
//            "<where>" +
//            "ml.user_id = #{userId} AND " +
//            "ml.src_id != #{userId} and " +
//            " status=0 " +
//            "<if test='type != null'>" +
//            "AND (" +
//            "<choose>" +
//            "<when test='type == 1'>" +
//            "ml.message_type = 3 OR ml.message_type = 5" +
//            "</when>" +
//            "<when test='type == 2'>" +
//            "ml.message_type = 14 OR ml.message_type = 2 OR ml.message_type = 15" +
//            "</when>" +
//            "<when test='type == 3'>" +
//            "ml.message_type = 6" +
//            "</when>" +
//            "<otherwise>" +
//            "ml.message_type > 20 or ml.message_type = 11 or ml.message_type = 12 or ml.message_type = 13 " +
//            "</otherwise>" +
//            "</choose>" +
//            ")" +
//            "</if>" +
//            "</where>" +
//            "</script>")
//    Long selectMessageListCounts(@Param("userId") Long userId, @Param("type") Integer type);
//
//    // 修改已读状态
//    @Update("<script>" +
//            "UPDATE app_message_list  " +
//            "<set>" +
//            " status = 1 " +
//            "</set>" +
//            "<where>" +
//            "<if test='messageId != null'>" +
//            "id = #{messageId} " +
//            "</if>" +
//            "<if test='messageId == null'>" +
//            " user_id=#{userId} " +
//            "</if>" +
//            "<if test='type != null'>" +
//            "AND (" +
//            "<choose>" +
//            "<when test='type == 1'>" +
//            "message_type = 3 OR message_type = 5" +
//            "</when>" +
//            "<when test='type == 2'>" +
//            "message_type = 14 OR message_type = 2 OR message_type = 15" +
//            "</when>" +
//            "<when test='type == 3'>" +
//            "message_type = 6" +
//            "</when>" +
//            "<otherwise>" +
//            "message_type>20 or message_type = 11 or message_type = 12 or message_type = 13 " +
//            "</otherwise>" +
//            "</choose>" +
//            ")" +
//            "</if>" +
//            "</where>" +
//            "</script>")
//    int updateReadStatus(MessageListQuery messageListQuery);
//
//
//    //-----------------------后台管理系统-----------------------
//
//    @Insert({
//            "<script>",
//            "INSERT INTO app_message_list(src_id, user_id, message_type, create_time, update_time, content,invisible_time,history_id) " +
//                    "SELECT 1, id, 50, sysdate(), sysdate(), #{content}, #{time},#{id} FROM app_user " +
//                    "<if test='ids != null and ids.size() > 0'>" +
//                    "WHERE id IN" +
//                    "<foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
//                    "#{id}" +
//                    "</foreach>" +
//                    "</if>" +
//                    "</script>"
//    })
//    int insertSystemMessages(@Param("content") String content, @Param("ids") List<Long> ids, @Param("time") Timestamp time, @Param("id") Long id);
//
////    // 系统消息
////    @Insert("INSERT INTO app_message_list(src_id, user_id, message_type, create_time, update_time, content) " +
////            "values( 1, 2688, 50, sysdate(), sysdate(), #{content})")
////    int insertSystemMessagess(String content);
//
//    // 节假日消息
//    @Insert("INSERT INTO app_special_message(user_id,content,img_url,create_time,update_time) " +
//            "SELECT id,#{content},#{imgUrl}, sysdate(), sysdate() " +
//            "FROM app_user")
//    int insertSpecialMessages(@Param("content") String content, @Param("imgUrl") String imgUrl);
//
//
//    @Select("select * FROM app_message_history WHERE type=#{type} limit #{pageBegin},#{pageSize}")
//    List<AppMessageHistoryVO> selectMessageHistory(@Param("type") Integer type,
//                                                   @Param("pageSize") Integer pageSize,
//                                                   @Param("pageBegin") Integer pageBegin);
//
//    @Select("select count(*) FROM app_message_history  WHERE type=#{type} ")
//    Integer selectCountByType(Integer type);
//
//    @Insert({
//            "<script>" +
//                    "INSERT INTO app_message_list (src_id, user_id, message_type, skip_id) VALUES " +
//                    "<foreach collection='userIds' item='item' separator=','>" +
//                    "(" +
//                    "#{item}," +
//                    "#{userId}," +
//                    "<choose>" +
//                    "<when test='type == 0'>3</when>" +
//                    "<when test='type == 1'>14</when>" +
//                    "<otherwise>2</otherwise>" +
//                    "</choose>," +
//                    "<choose>" +
//                    "<when test='type == 0'>#{id}</when>" +
//                    "<when test='type == 1'>#{item}</when>" +
//                    "<when test='type == 2'>#{id}</when>" +
//                    "</choose>" +
//                    ")" +
//                    "</foreach>" +
//                    "</script>"
//    })
//    Integer insertMessageLists(@Param("userIds") List<Long> userIds, @Param("userId") Long userId, @Param("id") Long id, @Param("type") int type);
//
//
//    @Select("select au.id,username name from app_message_list aml  left join app_user au on aml.user_id=au.id where aml.history_id =#{id}")
//    List<IdNameBO> queryIdAndNames(Long id);
    
}
